package com.example.common;

import com.example.pojo.SessionMessage;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.UserMessage;

import java.util.List;

public class BaseProperties {
    public static List<Message> convertToMessage(SessionMessage sessionMessage) {
        return switch (sessionMessage.getRole()) {
            case "user" -> List.of(new UserMessage(sessionMessage.getContent()));
            case "assistant" -> List.of(new AssistantMessage(sessionMessage.getContent()));
            default -> throw new IllegalArgumentException("Unknown message type: " + sessionMessage.getRole());
        };
    }
}

